function[X] = Simulate_CF(Results,PAR,Fees,shut_bidderentry,shut_sellerentry)
  

% Estimated params
    thetab   = [Results.mub,Results.kb,Results.shapeb];
    thetas   = [Results.mus,Results.ks,Results.shapes];
    eSo      = Results.eSo;
    eBo_posr = Results.eBo_posr;
    eBo_nor  = Results.eBo_nor;
    screeningvalue = Results.screeningvalue;
    PAR.sharenobidders = Results.sharenobidders;

    % CDFs
    CDFs = @(x) ggd_cdf(x,thetas);
    
    % Fees
    cB       = Fees.cB;
    cS       = Fees.cS;
    cL       = Fees.cL;
    cR       = Fees.cR;
    cP       = Fees.cP;   
        
    % Store simulation results
    X = Fees;
    
    % --- Case: re-calculate entry equilibrium (lambdastarnor, lambdastarposr, u0star) --- % 
    if shut_bidderentry ==0 && shut_sellerentry ==0 
            
        % Pre-calculate expected listing-level surplus
        [pibmat,pib0vec,pdfmat,pismat,pis0mat,v0vec,rvec,pipmat,pip0vec,pricemat,highvalmat,reservemat,saleprobmat,price0vec,highval0vec,volumemat,volume0vec] ...
            = piBS_MC(cB,cS,thetab,thetas,PAR);

        % Solve for u0* assuming that the marginal seller will set a positive reserve price
        X.u0star         = v0starfunc(cL+eSo,cP+eBo_posr,cR,thetas,pibmat,pib0vec,pdfmat,pismat,pis0mat,v0vec,0,screeningvalue,PAR);
        X.lambdastarnor  = lambdastarfunc(screeningvalue,X.u0star,cP+eBo_nor,pibmat,pib0vec,pdfmat,v0vec,1,PAR); 
        X.lambdastarposr = lambdastarfunc(screeningvalue,X.u0star,cP+eBo_posr,pibmat,pib0vec,pdfmat,v0vec,0,PAR); 
           
    % --- Case: partly re-calculate entry equilibrium (lambdastarnor, lambdastarposr but keep original sellers on platform) --- % 
    elseif shut_bidderentry == 0 && shut_sellerentry == 1 
         
        % Pre-calculate expected listing-level surplus
        [pibmat,pib0vec,pdfmat,pismat,pis0mat,v0vec,rvec,pipmat,pip0vec,pricemat,highvalmat,reservemat,saleprobmat,price0vec,highval0vec,volumemat,volume0vec] ...
            = piBS_MC(cB,cS,thetab,thetas,PAR);
        
        % Solve for lambdastar* - keeping seller entry threshold same as in baseline
        X.u0star         = Results.u0star;
        X.lambdastarnor  = lambdastarfunc(screeningvalue,X.u0star,cP+eBo_nor,pibmat,pib0vec,pdfmat,v0vec,1,PAR); 
        X.lambdastarposr = lambdastarfunc(screeningvalue,X.u0star,cP+eBo_posr,pibmat,pib0vec,pdfmat,v0vec,0,PAR); 
                  
    % --- Case: partly re-calculate entry equilibrium (u0star, but keep original number of bidders on platform) --- % 
    elseif shut_bidderentry == 1 && shut_sellerentry == 0 
             
        % Pre-calculate expected listing-level surplus
        [pibmat,pib0vec,pdfmat,pismat,pis0mat,v0vec,rvec,pipmat,pip0vec,pricemat,highvalmat,reservemat,saleprobmat,price0vec,highval0vec,volumemat,volume0vec] ...
            = piBS_MC(cB,cS,thetab,thetas,PAR);
        
        % Solve for u0* - keeping Number bidder distribution (r>0) same as in baseline
        X.u0star         = v0starfunc(cL+eSo,cP+eBo_posr,cR,thetas,pibmat,pib0vec,pdfmat,pismat,pis0mat,v0vec,0,screeningvalue,PAR,Results.lambdastarposr);
        X.lambdastarnor  = Results.lambdastarnor; 
        X.lambdastarposr = Results.lambdastarposr; 
                  
    % --- Case: keep entry fixed (one-sided market perspective)--- %
    else 
            
        % Pre-calculate expected listing-level surplus
        [pibmat,pib0vec,pdfmat,pismat,pis0mat,v0vec,rvec,pipmat,pip0vec,pricemat,highvalmat,reservemat,saleprobmat,price0vec,highval0vec,volumemat,volume0vec] ...
            = piBS_MC(cB,cS,thetab,thetas,PAR);
    end

    % Share of listings with no reserve price
    X.CDFu0star = CDFs(X.u0star);
    X.T         = Results.NS*X.CDFu0star;
    X.p_r0      = min((Results.T*Results.p_r0)/X.T,1); %when > 1, all sellers set no reserve. 
    X.M         = round(X.p_r0*X.lambdastarnor + (1-X.p_r0)*X.lambdastarposr)*X.T;
    
    % Calculate welfare and components
    [X.P,X.EB,X.EWB,X.ES,X.winbid,X.highval,X.reservesale,X.saleprob,X.Volume,X.EWBES,X.Total,X.EWB_posr,X.EWB_nor,X.ES_posr,X.ES_nor,X.winbid_posr,X.winbid_nor,X.saleprob_posr,X.saleprob_nor] ...
            = Piplatform(Fees,X,PAR,pipmat,pip0vec,pdfmat,v0vec,pibmat,pib0vec,pismat,pis0mat,pricemat,highvalmat,reservemat,saleprobmat,price0vec,highval0vec,volumemat,volume0vec);
end
       